package com.bigdata.appliance.controller;

import com.bigdata.appliance.service.IUserService;
import com.bigdata.appliance.vo.req.ChargeReqVO;
import com.bigdata.appliance.vo.req.GetWalletReqVO;
import com.bigdata.appliance.vo.req.LoginReqVO;
import com.bigdata.appliance.vo.req.RegisterReqVO;
import com.bigdata.appliance.vo.resp.LoginRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.math.BigDecimal;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author appliance-shop
 * @since 2023-12-23
 */
@RestController
@RequestMapping("/api")
@Api(value = "UserController", tags = {"用户接口"})
@EnableTransactionManagement
public class UserController {

    @Resource
    private IUserService iUserService;


    @PostMapping("/uniApp/user/register")
    @ApiOperation(value = "注册接口")
    public void register(@RequestBody @Valid RegisterReqVO vo) {
        iUserService.register(vo);
    }

    @PostMapping("/uniApp/user/login")
    @ApiOperation(value = "登录接口")
    public LoginRespVO login(@RequestBody @Valid LoginReqVO vo) {
        return iUserService.login(vo);
    }

    @PostMapping("/admin/user/charge")
    @ApiOperation(value = "充值接口")
    public void charge(@RequestBody @Valid ChargeReqVO vo) {
        iUserService.charge(vo);
    }

    @PostMapping("/admin/user/wallet")
    @ApiOperation(value = "钱包接口")
    public BigDecimal getWallet(@RequestBody @Valid GetWalletReqVO vo) {
        return iUserService.getWallet(vo);
    }

}
